package com.yanqu.road.server.cmd.activity.travelbook;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.TravelBookProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.travelbook.TravelBookModule;
import com.yanqu.road.server.protocol.Protocol;

/**
 * @Author : Cxp
 * @Time : 2024-11-12
 * @Description : 无双卡牌绑定门客
 */

@Cmd(code = Protocol.S_TRAVEL_BOOK_CHOOSE_PATRON, desc = "无双卡牌绑定门客")
public class TravelBookChoosePatronCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        TravelBookProto.TravelBookChoosePatronReq req =
                TravelBookProto.TravelBookChoosePatronReq.parseFrom(packet.getBytes());
        ret = player.getModule(TravelBookModule.class).choosePatron(req.getUserId(), req.getCardId(),
                req.getPatronId());
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {
            player.sendPacket(Protocol.U_TRAVEL_BOOK_CHOOSE_PATRON,
                    TravelBookProto.TravelBookChoosePatronResp.newBuilder().setRet(ret));
        }
    }
}
